package lock.ReentrantLock;

import org.junit.Test;

/**
 * @describe: 类描述信息
 * @author: morningcat.zhang
 * @date: 2019/4/22 5:35 PM
 */
public class MyArrayBlockQueueTest {

    @Test
    public void test1() throws InterruptedException {
        MyArrayBlockQueue<String> queue = new MyArrayBlockQueue(3);
        queue.put("qq");
        queue.put("ww");
        queue.put("ee");
        queue.put("rr");

        new Thread(() -> {
            try {
                queue.put("111");
                queue.put("222");
                queue.put("333");
                queue.put("444");
                queue.put("555");
                queue.put("666");
                queue.put("777");
                queue.put("888");
                queue.put("999");
                queue.put("101010");
                queue.put("111111");
                queue.put("12");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }).start();
        new Thread(() -> {
            try {
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
                System.out.println(queue.take());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        Thread.sleep(3000L);
    }
}
